package com.restaurant.validators;

import org.springframework.validation.Errors;
import org.springframework.validation.Validator;

import com.restaurant.domain.Inventory;

public class InventoryFormValidator implements Validator{

	
	@Override
	public boolean supports(Class<?> arg0) {
		return Inventory.class.isAssignableFrom(arg0);
	}

	@Override
	public void validate(Object arg0, Errors errors) {
		//ValidationUtils.rejectIfEmptyOrWhitespace(arg1, "inventoryName", "inventory.name");
		Inventory inventory = (Inventory) arg0;
		if(inventory.getInventoryName().trim().length()<=0){
			errors.rejectValue("inventoryName", "inventory.name");
		}		
		
		
	}

}
